package com.boot.ch7.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局Exception拦截器
 */

@ControllerAdvice
@ResponseBody
public class GlobalExceptionHandler {

    @ExceptionHandler(value = ServiceException.class)
    public String bindExceptionHandler(ServiceException serviceException) {
        String msg = serviceException.errorMsg;
        String code = serviceException.errorCode;
        return msg;
    }
}
